package top.soulblack.purchasesale.mapper;

import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import top.soulblack.purchasesale.model.GoodsSize;

import java.util.List;

/**
 * create by 小川
 */

@Mapper
public interface GoodsSizeMapper {

    int deleteById(Integer id);

    int insert(GoodsSize record);

    int insertSelective(GoodsSize record);

    GoodsSize selectByPrimaryKey(Integer id);

    int updateByPrimaryKeySelective(GoodsSize record);

    int updateByPrimaryKey(GoodsSize record);

    List<GoodsSize> selectGoodsSizeIdByBarCode(@Param("barCode") String barCode);


    @Select("select * from goods_size")
    List<GoodsSize> selectAll();

    @Select("select name from goods_size where id = #{id}")
    String selectById(@Param("id") Integer id);

    @Select("select distinct `group` from goods_size")
    List<String> selectGroups();

    @Insert("insert into goods_size (name, `group`, sort, status) values (#{name}, #{group}, #{sort}, #{status})")
    void addSize(GoodsSize goodsSize);

    @Select("select * from goods_size where name = #{sizeName} order by sort")
    List<GoodsSize> selectForName(@Param("sizeName") String sizeName);

    @Select("select * from goods_size where `group` = #{group} order by sort")
    List<GoodsSize> selectForGroup(@Param("group") String group);

    @Select("select count(*) from goods_size where name = #{name}")
    int existSize(String name);

    @Select("select size from goods where size = #{id}")
    List<Integer> selectSize(@Param("id") Integer id);
}
